﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace HD_CoCaNgua
{
    public class CMap
    {
        Bitmap _bmpBackground;

        public Bitmap BmpBackground
        {
            get { return _bmpBackground; }
            set { _bmpBackground = value; }
        }


        public Rectangle getRectView()
        {
            return new Rectangle(_xView, _yView, _widthView, _heightView);
        }

        

        int _xView = 0;

        public int XView
        {
            get { return _xView; }
            set { _xView = value; }
        }
        int _yView = 0;

        int _widthView;

        public int WidthView
        {
            get { return _widthView; }
            set { _widthView = value; }
        }
        int _heightView;

        public int HeightView
        {
            get { return _heightView; }
            set { _heightView = value; }
        }

        public int YView
        {
            get { return _yView; }
            set { _yView = value; }
        }

       

        public CMap(int width, int height)
        {
            _widthView = width;
            _heightView = height;

        }

        public void DisposeMap()
        {
            if (_bmpBackground != null)
            {
                _bmpBackground.Dispose();
                _bmpBackground = null;
            }
                       
        }

        
        
        public void LoadMapFromFile(string strPath)
        {
            DisposeMap();

            if (_bmpBackground == null)
                _bmpBackground = new Bitmap(strPath);
            
        }
        

        public void RollMap(int dx, int dy)
        {
            if (0 <= _xView + dx && _xView + dx <= _widthView)
                _xView += dx;

            if (0 <= _yView + dy && _yView + dy <= _heightView)
                _yView += dy;  

        }


    }
}
